<%@ include file="/WEB-INF/jsp/taglib.jsp" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>交易明细</title>

    <!-- Bootstrap -->
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/Transaction.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->


    <script type="text/javascript" src="/js/web3.min.js"></script>
    <script type="text/javascript" src="/js/bignumber.js"></script>

    <script src="/js/jquery-2.2.3.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <script src="/js/Transaction.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            // 初始化web3
            if (typeof web3 !== 'undefined') {
                web3 = new Web3(web3.currentProvider);
            } else {
                web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
            }

            var txHash = '${transactionHash}';
            var transaction = web3.eth.getTransaction(txHash);

            var blockHash = "<a href='/wallet/block/" + transaction.blockHash + "' class='record-main'>" + transaction.blockHash + "</a>";
            var transactionDetail = document.getElementById("transaction-detail");
            var str = "<tr><td>Hash</td>" +
                "<td>" + transaction.hash + "</td></tr>" +
                "<tr><td>Account Nonce</td>" +
                "<td>" + transaction.nonce + "</td></tr>" +
                "<tr><td>Block Hash</td>" +
                "<td>" + blockHash + "</td></tr>" +
                "<tr><td>From</td>" +
                "<td>" + transaction.from + "</td></tr>" +
                "<tr><td>To</td>" +
                "<td>" + transaction.to + "</td></tr>" +
//                "<tr><td>Amount</td>" +
//                "<td>" + web3.fromWei(transaction.value, 'ether') + "</td></tr>" +
                "<tr><td>Gas Price</td>" +
                "<td>" + transaction.gasPrice + " Wei" + "</td></tr>" +
                "<tr><td>Gas</td>" +
                "<td>" + transaction.gas + "</td></tr>";
            transactionDetail.innerHTML = str;
        });
    </script>

    <c:import url="/WEB-INF/jsp/frontend/head.jsp" />
    <c:import url="/WEB-INF/jsp/frontend/activity/script.jsp" />
</head>
<body>

<div class="head">
    <c:import url="/WEB-INF/jsp/frontend/header.jsp"/>
</div>

<div class="container-wrap transaction-body">
    <div class="container">
        <div class="row transaction-container">
            <div class="col-md-11 transaction-head">交易明细</div>
            <div class="col-md-11 transaction-divider"></div>
            <div class="col-md-11 table-responsive transaction-table">
                <table class="table table-bordered" id="transaction-detail">

                </table>
            </div>
        </div>
    </div>
</div>
</body>
</html>
